package framework.test;

import java.util.HashMap;
import java.util.Map;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.engineering.elink.co.UserCo;
import com.engineering.elink.common.Constant;
import com.engineering.elink.dao.TokenAuthenticationMapper;
import com.engineering.elink.service.RedisService;
import com.engineering.elink.service.UserService;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:spring-mybatis.xml" })
public class AddUser {

	@Autowired
	private RedisService redisService;
	@Autowired
	private TokenAuthenticationMapper tokenAuthenticationMapper;
	@Autowired
	private UserService userService;

	@Test
	public void test() {
		UserCo userCo = null;
		Map<String, Object> map = new HashMap<String, Object>();
		String[][] userInfo = { 
//				{ "13917031678", "123456", "张承兵","ChengbingZhang@elinkgroup.net"},
//				{ "13661587322", "123456", "邹妍君","YanjunZou@elinkgroup.net" },
//				{ "15821326529", "123456", "吴辉","huiwu@elinkgroup.net" },
//				{ "13482486718", "123456", "张丽影","liyingzhang@elinkgroup.net" },
//				{ "18419702624", "123456", "马秀秀","xiuxiuma@elinkgroup.net" },
//				{ "13264094826", "123456", "郭君","junguo@elinkgroup.net" },
//				{ "17721259023", "123456", "陈洁","jiecheng@elinkgroup.net" },
//				{ "13248377637", "123456", "薛明浩","minghaoxue@elinkgroup.net" },
//				{ "18501265546", "123456", "安宝","baoan@elingkgroup.net" },
//				{ "13795396902", "123456", "杨建巍","jianweiyang@elinkgroup.net" },
//				{ "15214379369", "123456", "赵海峰","haifengzhao@elinkgroup.net" },
//				{ "18321948716", "123456", "黄小军","xiaojunhuang@elinkgroup.net" },
//				{ "13926537532", "123456", "吴琼","qiongwu@elinkgroup.net" },
//				{ "18116261558", "123456", "马燕","yanma@elinkgroup.net" },
//				{ "18645040875", "123456", "刘天航","tianhangliu@elinkgroup.net" },
				{ "13564627474", "123456", "胡佳寅","jiayinhu@elinkgroup.net" }
				};
		for (int i = 0; i < userInfo.length; i++) {
			userCo = new UserCo();
			map.put("phone", userInfo[i][0]);
			map.put("verifyCode", "111111");
//			cacheManager.getCache("verifyCodeCache").put(
//					new Element("token", map, TokenExpireTime.VerifyCodeTTI,
//							TokenExpireTime.VerifyCodeTTL));
			redisService.putSeedObjectMap(Constant.verifyCodeCache, "token", map, Constant.validTime);
			userCo.setVerifyCode("111111");
//			userCo.setVerifyToken("token");
			userCo.setPhone(userInfo[i][0]);
			userCo.setEmail(userInfo[i][3]);
//			userCo.setNickname(userInfo[i][2]);
			userCo.setPasswd(userInfo[i][1]);
			userService.reg(userCo);
			map.clear();
		}
	}
}
